package com.swu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.swu.common.Result;
import com.swu.dto.MedicalRecordQueryDTO;
import com.swu.service.MedicalRecordService;
import com.swu.vo.MedicalRecordVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "病案管理", description = "病案上传和管理相关接口")
@RestController
@RequestMapping("/medical-record")
@RequiredArgsConstructor
public class MedicalRecordController {

    private final MedicalRecordService medicalRecordService;

    @Operation(summary = "分页查询病案信息")
    @PostMapping("/query")
    public Result<Page<MedicalRecordVO>> queryMedicalRecords(@RequestBody @Validated MedicalRecordQueryDTO queryDTO) {
        return Result.success(medicalRecordService.queryMedicalRecords(queryDTO));
    }

    @Operation(summary = "上传病案", description = "上传病案PDF文件并解析入库")
    @PostMapping("/upload")
    public Result<String> uploadMedicalRecord(
            @Parameter(description = "病案PDF文件", required = true)
            @RequestParam("file") MultipartFile file) {
        return medicalRecordService.processMedicalRecordPdf(file);
    }
} 